<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>闭包</title>
</head>
<body>
    <script type="text/javascript">
        var myObject = (function(){
            var value = 0;
            return {
                increment:function(inc){
                    value += typeof inc === 'number' ? inc : 1;
                },
                getValue:function(){
                    return value;
                }
            }
        })();
        console.log(">>>" + myObject.increment(10));
        console.log("getValue:"+myObject.getValue());
    </script>
</body>
</html>